<?php
/**
 *      [迷你云] (C)2009-2012 南京恒为网络科技.
 *   软件仅供研究与学习使用，如需商用，请访问www.miniyun.cn获得授权
 * 
 */
?>
<?php

class ServerRegistry extends CMiniyunModel {

    public static function model($className = __CLASS__) {
        return parent::model ( $className );
    }

    public function primaryKey()
    {
        return 'osr_id';
                    }


    public function tableName() {
        return Yii::app ()->params ['tablePrefix'] . 'server_registry';
    }

    public function relations() {
        return array ();
    }

    public function attributeLabels() {
        return array ()

        ;
    }
    
    public static function getApps() {
        return array (
        1 => Yii::app ()->params ["app"] ["name"] . "网页版",
        2 => Yii::app ()->params ["app"] ["name"] . "Windows客户端",
        4 => Yii::app ()->params ["app"] ["name"] . "Android版本",
        6 => Yii::app ()->params ["app"] ["name"] . "iPhone版",
        7 => Yii::app ()->params ["app"] ["name"] . "iPad版",
        8 => Yii::app ()->params ["app"] ["name"] . "Dev" );
    }


    
    public function disabledApps($appIds){
        $this->updateAll(array("osr_enabled"=>0), "osr_id in(".$appIds.")");
    }

    
    public function enabledApps($appIds){
        $this->updateAll(array("osr_enabled"=>1), "osr_id in(".$appIds.")");
    }


    
    public function deleteApps($appIds){
        $this->deleteAll("osr_id in(".$appIds.")");
    }


    
    public function enabledCount(){
        return $this->count("osr_enabled=1 && osr_usa_id_ref != -1");
    }

    
    public function disabledCount(){
        return $this->count("osr_enabled=0 && osr_usa_id_ref = !-1");
    }

    
    public static function getAppIcons() {
        return array (
        1 => "/statics/images/web-32.png",
        2 => "/statics/images/windows-32.png",
        4 => "/statics/images/android-32.png",
        6 => "/statics/images/iphone-32.png",
        7 => "/statics/images/ipad-32.png",
        8 => "/statics/images/dev-32.png" );
    }
}